/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import junit.framework.TestCase;

import java.text.ParseException;
import java.util.Locale;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class ContentLanguageHeaderParserTest extends TestCase {
    public ContentLanguageHeaderParserTest(String name) {
        super(name);
    }

    public void test() {
        final byte[] data = "Content-Language: en-us, fr,ru".getBytes();
        final ContentLanguageHeaderParser parser = new ContentLanguageHeaderParser();
        ContentLanguageHeaderImpl[] headers;
        try {
            headers = parser.parse(data, 17, data.length);
        } catch (ParseException e) {
            fail(e.getMessage());
            return;
        }
        assertNotNull("The result is null!", headers);
        assertEquals("The length of the result is wrong!", 3, headers.length);
        assertEquals("The language is wrong!", new Locale("en", "us"), headers[0].getContentLanguage());
        assertEquals("The string representation is wrong!", "Content-Language: en-us", headers[0].toString());
        assertEquals("The language is wrong!", new Locale("fr"), headers[1].getContentLanguage());
        assertEquals("The string representation is wrong!", "Content-Language: fr", headers[1].toString());
        assertEquals("The language is wrong!", new Locale("ru"), headers[2].getContentLanguage());
        assertEquals("The string representation is wrong!", "Content-Language: ru", headers[2].toString());
    }
}
/*
 * $Log$
 */